import pymysql
import pandas as pd
import numpy as np

import os
import sys
current_path = os.path.split(os.path.realpath(__file__))[0]
sys.path.append(current_path)

print(current_path)

def getmatrix():
    barrier_map = []
    file = os.path.join(current_path,'map.csv')
    df = pd.read_csv('map.csv')
    codes = df.values
    rows, cols = codes.shape
    for i in range(rows):
        for j in range(cols):
            if codes[i, j] != 1: barrier_map.append([i, j])
    return barrier_map
# connect = pymysql.connect(host='172.18.162.198',
    #                         user='root',
    #                         password='123456',
    #                         port=3306,
    #                         charset="utf8",
    #                         autocommit=True,
    #                         database="test"
    #                         )
    # cursor = connect.cursor()
    # sql = "select x_row, y_col from matrixmap where type_value = 0"
    # cursor.execute(sql)
    # result = cursor.fetchall()
    # for i in result:
    #     barrier_map.append([i[0] + 44, i[1] + 94])
